Attribute VB_Name = "resize"
Option Explicit
Dim objects() As Object
Dim baifen() As Double
Dim rowes() As Long
Public Function setrows(rows As Long)
    ReDim rowes(rows)
End Function
Public Function setrowandcolumn(Row As Long, column As Long)
    rowes(Row) = column
End Function
Public Function addobject(a As Object, i As Integer, Row As Integer, tall As Long, tags As String)
    Set objects(Row, i) = a
    objects(Row, i).Top = tall
    objects(Row, i).Tag = tags
End Function
Public Function objectdimi(i As Long, Row As Long)
    Dim j As Long
    j = i * 2 + 1
    ReDim objects(Row, i)
    ReDim baifen(Row, j)
End Function
Public Function setbaifen(a As Object)
    Dim ll_i, ll_j As Long
    Dim ll_a, ll_b
    For ll_j = 1 To UBound(rowes)
      For ll_i = 1 To rowes(ll_j) * 2 + 1
        If ll_i = 1 Then
           baifen(ll_j, ll_i) = objects(ll_j, ll_i).Left / a.Width
        ElseIf ll_i = rowes(ll_j) * 2 + 1 Then
           baifen(ll_j, ll_i) = (a.Width - objects(ll_j, (rowes(ll_j) - 1)).Left - objects(ll_j, (rowes(ll_j) - 1)).Width) / a.Width
        ElseIf (ll_i Mod 2) = 0 Then
           baifen(ll_j, ll_i) = (objects(ll_j, (ll_i / 2)).Width) / a.Width
        Else
           ll_a = CInt(ll_i / 2 + 0.5)
           baifen(ll_j, ll_i) = objects(ll_j, ll_a).Left / a.Width
        End If
      Next ll_i
    Next ll_j
End Function
Public Function objectresize(f As Object, a As Object, w As Integer)
    Dim ll_i, ll_j As Long
    
    a.Width = f.Width - 200
    For ll_j = 1 To UBound(rowes)
        For ll_i = 1 To rowes(ll_j)
            objects(ll_j, ll_i).Left = baifen(ll_j, (ll_i * 2 - 1)) * a.Width
            If objects(ll_j, ll_i).Tag = "Y" Then
                objects(ll_j, ll_i).Width = baifen(ll_j, (ll_i * 2)) * a.Width
            End If
        Next ll_i
    Next ll_j
End Function
Public Function init()
    Call setrows(5)
    Call setrowandcolumn(1, 6)
    Call setrowandcolumn(2, 3)
    Call setrowandcolumn(3, 9)
    Call setrowandcolumn(4, 5)
    Call setrowandcolumn(5, 7)
    Call objectdimi(12, 5)
    Call addobject(frmMain.Label4, 1, 1, 270, "Y")
    Call addobject(frmMain.CmbSL, 2, 1, 250, "Y")
    Call addobject(frmMain.Label5, 3, 1, 280, "Y")
    Call addobject(frmMain.Combo1, 4, 1, 250, "Y")
    Call addobject(frmMain.Command4, 5, 1, 250, "Y")
    Call addobject(frmMain.Check4, 6, 1, 270, "Y")
    
    Call addobject(frmMain.Frame2, 1, 2, 570, "Y")
    Call addobject(frmMain.Frame3, 2, 2, 220, "Y")
    Call addobject(frmMain.Frame4, 3, 2, 570, "Y")
     
   
'    Call addobject(frmMain.Check1(1), 1, 3, 800, "Y")
'    Call addobject(frmMain.Check1(2), 2, 3, 800, "Y")
'    Call addobject(frmMain.Check1(4), 3, 3, 800, "Y")
    Call addobject(frmMain.OptL, 1, 3, 750, "Y")
    Call addobject(frmMain.Label3, 2, 3, 390, "Y")
    Call addobject(frmMain.Label8, 3, 3, 390, "Y")
    Call addobject(frmMain.ADM, 4, 3, 550, "Y")
    Call addobject(frmMain.PatName, 5, 3, 400, "Y")
    Call addobject(frmMain.wards, 6, 3, 550, "Y")
    Call addobject(frmMain.Command1, 7, 3, 550, "Y")
    Call addobject(frmMain.OptS, 8, 3, 750, "Y")
    Call addobject(frmMain.List1, 9, 3, 200, "Y")
    
'    Call addobject(frmMain.Check1(3), 1, 4, 1250, "Y")
'    Call addobject(frmMain.Check1(6), 2, 4, 1250, "Y")
'    Call addobject(frmMain.Check1(5), 3, 4, 1250, "Y")
    Call addobject(frmMain.CYDY, 1, 4, 1250, "Y")
    Call addobject(frmMain.Label1, 2, 4, 950, "Y")
    Call addobject(frmMain.DateC1, 3, 4, 1100, "Y")
    Call addobject(frmMain.Command2, 4, 4, 1100, "Y")
    Call addobject(frmMain.DTP_Time1, 5, 4, 860, "Y")
    
    Call addobject(frmMain.Check2, 1, 5, 1900, "Y")
    Call addobject(frmMain.Check3, 2, 5, 1900, "Y")
    Call addobject(frmMain.RegisNum, 3, 5, 1900, "Y")
    Call addobject(frmMain.Label2, 4, 5, 1500, "Y")
    Call addobject(frmMain.DateC2, 5, 5, 1650, "Y")
    Call addobject(frmMain.Command3, 6, 5, 1650, "Y")
    Call addobject(frmMain.DTP_Time2, 7, 5, 1420, "Y")
        
    Call setbaifen(frmMain.Frame1)
    Call setbaifen(frmMain.Frame2)
    Call setbaifen(frmMain.Frame3)
    Call setbaifen(frmMain.Frame4)
    Call setbaifen(frmMain.Frame5)
    Call setbaifen(frmMain.Frame6)
    Call setbaifen(frmMain.Frame7)

    
    
    
    
    '  frmMain.MSFlexGrid1(2).Top = frmMain.MSFlexGrid1(1).Top
    '  frmMain.MSFlexGrid1(2).Left = frmMain.MSFlexGrid1(1).Left
    '  frmMain.MSFlexGrid1(2).Height = frmMain.MSFlexGrid1(1).Height
    '  frmMain.MSFlexGrid1(2).Width = frmMain.MSFlexGrid1(1).Width
    '  frmMain.MSFlexGrid1(3).Top = frmMain.MSFlexGrid1(1).Top
    '  frmMain.MSFlexGrid1(3).Left = frmMain.MSFlexGrid1(1).Left
    '  frmMain.MSFlexGrid1(3).Height = frmMain.MSFlexGrid1(1).Height
    '  frmMain.MSFlexGrid1(3).Width = frmMain.MSFlexGrid1(1).Width
    '  frmMain.MSFlexGrid1(4).Top = frmMain.MSFlexGrid1(1).Top
    '  frmMain.MSFlexGrid1(4).Left = frmMain.MSFlexGrid1(1).Left
    '  frmMain.MSFlexGrid1(4).Height = frmMain.MSFlexGrid1(1).Height
    '  frmMain.MSFlexGrid1(4).Width = frmMain.MSFlexGrid1(1).Width
    '  frmMain.MSFlexGrid1(5).Top = frmMain.MSFlexGrid1(1).Top
    '  frmMain.MSFlexGrid1(5).Left = frmMain.MSFlexGrid1(1).Left
    '  frmMain.MSFlexGrid1(5).Height = frmMain.MSFlexGrid1(1).Height
    '  frmMain.MSFlexGrid1(5).Width = frmMain.MSFlexGrid1(1).Width
    '  frmMain.MSFlexGrid1(6).Top = frmMain.MSFlexGrid1(1).Top
    '  frmMain.MSFlexGrid1(6).Left = frmMain.MSFlexGrid1(1).Left
    '  frmMain.MSFlexGrid1(6).Height = frmMain.MSFlexGrid1(1).Height
    '  frmMain.MSFlexGrid1(6).Width = frmMain.MSFlexGrid1(1).Width
    
End Function

